var popedomsDialog = new Dialog({
			showdiv : "popedomsDialog",
			title : "选择权限列表",
			x : 500,
			y : 500
		});
rootDialog.childDialog = popedomsDialog;
function initSelectPopedoms(roleid) {
	popedomsDialog.title="选择权限列表";
	openDialog(popedomsDialog,'' ,function() {
		var chakantable = document.createElement("table");
		chakantable.style.align = "center";
		chakantable.className="table";
		 popedomsDialog.contentdiv.appendChild(chakantable);
		var chakanthead = document.createElement("<thead>");
		chakanthead.setAttribute('id', 'theadzone');
		chakantable.appendChild(chakanthead);
		var chakantr = document.createElement("<tr>");
		chakantr.setAttribute("id", "tou");
		chakanthead.appendChild(chakantr);
		var chakanth1 = document.createElement("<td>");
		chakantr.appendChild(chakanth1);

		var chakanth2 = document.createElement("<td>");
		chakantr.appendChild(chakanth2);

		var chakanth3 = document.createElement("<td>");
		chakantr.appendChild(chakanth3);

		var chakanth4 = document.createElement("<td>");
		chakantr.appendChild(chakanth4);

		chakanth1.innerHTML = "<b>权限编号</b>";
		chakanth2.innerHTML = "<b>权限名</b>";
		chakanth3.innerHTML = "<b>权限描述</b>";
		chakanth4.innerHTML = "<b>全选/反选<input type='checkbox' name='quanfan' value='' onclick='ioCheckbox(\"popedomcheckbox\")'></b>";

		var chakantbody = document.createElement("tbody");
		chakantbody.setAttribute('id', 'selectPopedomslistZone_data');
		chakantable.appendChild(chakantbody);
		var chakantfoot = document.createElement("div");
		chakantfoot.setAttribute('id', 'selectPopedomslistZone_bar');
		 popedomsDialog.contentdiv.appendChild(chakantfoot);
		selectPopedoms = {
			navigationsize : 10,
			paramname : 'selectPopedoms',
			page : 1,
			exefunc:function() {
					Role.findPopsByRoleid(selectPopedoms.roleid, function(data) {
								for (var i = 0; i < data.length; i++) {
									$setV('popedomcheckbox', data[i]);
								}
							});},
			funcname : 'Popedom.findAllPopedomPageIsUse()',
			cellfuncs : selectPopedomsCellfuncs,
			pagesize : 10,
			count : 'Popedom.getCountIsUse()',
			idname : 'selectPopedomslistZone'
		};
		selectPopedoms.roleid = roleid;
		send(selectPopedoms);
		
		var divform =  popedomsDialog.contentdiv.appendChild(document
				.createElement("div"));
		var submitbutton = divform
				.appendChild(document.createElement("button"));
		submitbutton.setAttribute('name', 'submitbutton');
		submitbutton.setAttribute('id', 'submitbutton');
		submitbutton.setAttribute('value', '应用');
		submitbutton.innerHTML="应用";
		submitbutton.onclick = function() {
			var selectv =$getV('popedomcheckbox').split(';').length>0
					? $getV('popedomcheckbox').split(';')
					: ["0"];
			var selectnv = $ngetV('popedomcheckbox').split(';').length>0
					? $ngetV('popedomcheckbox').split(';')
					: ["0"];
			Role.addPopedoms(roleid, selectv, selectnv, function(data) {
						if (data == 1) {
							alert('为角色添加权限成功');
						} else {
							alert('为角色添加权限失败');
						}
					});
		};
		

	});
}
var selectPopedoms;
var selectPopedomsCellfuncs = [function(data) {
			return data.pid;
		}, function(data) {
			return data.pname;
		}, function(data) {
			return data.ptext;
		}, function(data) {
			var checkbox = document.createElement('input');
			checkbox.setAttribute('type', 'checkbox');
			checkbox.setAttribute('name', 'popedomcheckbox');
			checkbox.setAttribute('id', 'popedomcheckbox');
			checkbox.setAttribute('value', data.pid);
			return checkbox;
		}];